/*
 * Filename: e:\OwnProject\FlutterPro\flutter_app_01\lib\views\typelist\index.dart
 * Path: e:\OwnProject\FlutterPro\flutter_app_01\lib\views\typelist
 * Created Date: Saturday, April 3rd 2021, 5:14:54 pm
 * Author: chenfayun
 * 
 * Copyright (c) 2021 Your Company
 */

import 'package:flutter/cupertino.dart';
import '../../public.dart';

class TypeSelect extends StatelessWidget {
  const TypeSelect({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    var list = AccountList.categories.keys.toList();
    return CupertinoPageScaffold(
      navigationBar: const CupertinoNavigationBar(
        border: Border(bottom: BorderSide.none),
        backgroundColor: Colors.white,
        middle: Text('Choose Account Type'),
      ),
      child: SafeArea(
        child: Material(
          child: ListView.builder(
            itemCount: list.length,
            itemBuilder: (context, index) {
              final category = AccountList.categories[list[index]] as Category;
              return ListTile(
                leading: Image.asset(category.src, width: 40, height: 40),
                tileColor: Colors.white,
                contentPadding: const EdgeInsets.symmetric(
                  vertical: 12,
                  horizontal: 15,
                ),
                title: Row(children: [Text(category.name)]),
                trailing: const Icon(Icons.chevron_right),
                onTap: () {
                  RouterHelper.navigator.pop(category);
                },
              );
            },
          ),
        ),
      ),
    );
  }
}
